package com.webchat.ugc.controller.mall;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.request.mall.CreateProductPaymentOrderReqVO;
import com.webchat.domain.vo.request.mall.PreCreateProductOrderReqVO;
import com.webchat.domain.vo.response.mall.MallProductOrderResponseVO;
import com.webchat.domain.vo.response.mall.MallUserProductOrderResponseVO;
import com.webchat.rmi.ugc.mall.MallProductOrderClient;
import com.webchat.ugc.service.mall.MallProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class MallProductOrderController implements MallProductOrderClient {


    @Autowired
    private MallProductOrderService productOrderService;


    @Override
    public APIResponseBean<String> preCreateOrder(@RequestBody PreCreateProductOrderReqVO preCreateProductOrderReq) {

        String orderNo = productOrderService.preCreateOrder(preCreateProductOrderReq);
        return APIResponseBeanUtil.success(orderNo);
    }

    @Override
    public APIResponseBean<MallUserProductOrderResponseVO> userOrder(String userId, String orderNo) {
        MallUserProductOrderResponseVO userOrderInfo = productOrderService.getUserOrder(userId, orderNo);
        return APIResponseBeanUtil.success(userOrderInfo);
    }

    @Override
    public APIResponseBean<String> createPaymentOrder(CreateProductPaymentOrderReqVO createProductPaymentOrderReqVO) {

        String paymentOrderId = productOrderService.createPaymentOrder(createProductPaymentOrderReqVO);
        return APIResponseBeanUtil.success(paymentOrderId);
    }

}
